package com.czl.elm.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

public class TimeUtil {
    public static LocalDateTime StringToLocalDateTime(String time){
        DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.parse(time,dateTimeFormatter);
    }

    public static LocalDate StringToLocalDate(String time){
        DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return LocalDate.parse(time,dateTimeFormatter);
    }

    public static LocalDateTime StringToLocalDateTimeNoSecond(String time){
        DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        return LocalDateTime.parse(time,dateTimeFormatter);
    }

    public static Long LocalDateTimeToSecond(LocalDateTime localDateTime){
        return localDateTime.toEpochSecond(ZoneOffset.of("+8"));
    }


}
